<?php
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net 
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : mail_content.manage.php   FILE_PATH : D:\webroot\mulitishop\system\mail_content.manage.php
 * ....邮件发送内容管理
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author 网城创想多用户商城开发团队 php_netproject@yahoo.com.cn
 * @package 
 * @subpackage 
 * @version Tue Sep 18 17:22:08 CST 2007
 */


require_once("../global.inc.php");

class SysMailContentManage extends SystemFrameWork{
	/**
	 * 邮件发送内容对象
	 *
	 * @var obj
	 */
	var $obj_mail;
	/**
	 * 分页对象
	 *
	 * @var obj
	 */
	var $obj_page;
	/**
	 * 验证对象
	 *
	 * @var obj
	 */
	var $obj_validate;
	
	function main(){
		/**
		 * 邮件发送内容对象
		 */
		if (!is_object($this->obj_mail)){
			require_once("mailcontent.class.php");
			$this->obj_mail = new MailContentClass();
		}
		/**
		 * 创建验证对象
		 */
		if (!is_object($this->obj_validate)){
			require_once("commonvalidate.class.php");
			$this->obj_validate = new CommonValidate();
		}
		
		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("system");
		
		/**
		 * 语言包
		 */
		$this->getlang("system");
		
		switch($this->_input['action']){
			case "add":
				$this->_add_mail_content();
				break;
			case "addsave":
				$this->_add_save_mail_montent();
				break;
			case "modi":
				$this->_get_mail_content();
				break;
			case "save":
				$this->_modi_mail_content();
				break;
			case "list":
				$this->_get_mail_contentList();
				break;
			default:
				$this->_get_mail_contentList();
		}
	}
	/**
	 * 列出邮件发送内容列表
	 *
	 */
	function _get_mail_contentList(){
		/**
		 * 初始化分页类
		 */
		if (!is_object($this->obj_page)){
			require_once("commonpage.class.php");
			$this->obj_page = new CommonPage();
		}
		$this->obj_page->pagebarnum(5);
		$mail_array = $this->obj_mail->getMailContentList($this->obj_page);
		$page_list = $this->obj_page->show(1);
		
		/**
		 * 页面输出
		 */
		$this->output("mail_array", $mail_array);
		$this->output("page_list", $page_list);
		$this->showpage("sys_mailcontent.manage");
	}
	/**
	 * 显示邮件内容
	 *
	 */
	function _get_mail_content(){
		$mail_array = $this->obj_mail->getMailContent($this->_input['genre']);
		//print_r($mail_array);
		//$this->output("mail_genre", $this->_b_config['mailgenre']);
		$this->output("mail_content_array", $mail_array);   //输出发送邮件内容
		$this->output("radio_mail_open", Common::showForm_Radio("rdoopen","",$this->_b_config['openstate'],$mail_array['ifopen']));
		$this->showpage("sys_mailcontent.modi");
	}
	
	/**
	 * 修改邮件内容
	 *
	 */
	function _modi_mail_content(){
		$this->obj_mail->modiMailContent($this->_input);
		//print_r($this->_input);exit;
		$url = "./system/mailcontent.manage.php";
		$this->redirectPath("common",$url);
	}
	
	/**
	 * 新增邮件内容
	 */
	function _add_mail_content(){
		$this->showpage("sys_mailcontent.add");
	}
	
	/**
	 * 保存新增邮件内容
	 */
	function _add_save_mail_montent(){
		/**
		 * 验证表单信息
		 */
		$this->obj_validate->validateparam = array(
		array("input"=>$this->_input["txtMailTitle"],"require"=>"true","message"=>$this->_lang['errMailTitle']),
		array("input"=>$this->_input["txtMailGenre"],"require"=>"true","message"=>$this->_lang['errMailGenre']),
		array("input"=>$this->_input["txtMaildesc"],"require"=>"true","message"=>$this->_lang['errMaildesc']),
		array("input"=>$this->_input["txtContent"],"require"=>"true","message"=>$this->_lang['errMailContent']),
		);
		$error = $this->obj_validate->validate();

		if($error != ""){
			$url = "./system/mailcontent.manage.php?action=add";
			$this->redirectPath("succ",$url,$error);
		}
		/**
		 * 判断邮件标识是否重复
		 */
		$array = $this->obj_mail->getMailContent($this->_input['txtMailGenre']);
		if (!empty($array)){
			$url = "./system/mailcontent.manage.php?action=add";
			$this->redirectPath("succ",$url,$this->_lang['errMailGenreRepeat']);
		}

		$this->obj_mail->addMailContent($this->_input);
		$url = "./system/mailcontent.manage.php";
		$this->redirectPath("succ",$url,'操作成功');
	}
	
}

$mail_content = new SysMailContentManage();
$mail_content->main();
unset($mail_content);
?>